package com.ruoyi.web.controller.zzw;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ZzwBookingInfo;
import com.ruoyi.system.service.IZzwBookingInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 预约咨询Controller
 *
 * @author linzhaojie
 * @date 2024-06-02
 */
@RestController
@RequestMapping("/zzw/booking")
public class ZzwBookingInfoController extends BaseController
{
    @Autowired
    private IZzwBookingInfoService zzwBookingInfoService;

    /**
     * 查询预约咨询列表
     */
    @PreAuthorize("@ss.hasPermi('zzw:booking:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZzwBookingInfo zzwBookingInfo)
    {
        startPage();
        List<ZzwBookingInfo> list = zzwBookingInfoService.selectZzwBookingInfoList(zzwBookingInfo);
        return getDataTable(list);
    }

    /**
     * 导出预约咨询列表
     */
    @PreAuthorize("@ss.hasPermi('zzw:booking:export')")
    @Log(title = "预约咨询", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ZzwBookingInfo zzwBookingInfo)
    {
        List<ZzwBookingInfo> list = zzwBookingInfoService.selectZzwBookingInfoList(zzwBookingInfo);
        ExcelUtil<ZzwBookingInfo> util = new ExcelUtil<ZzwBookingInfo>(ZzwBookingInfo.class);
        util.exportExcel(response, list, "预约咨询数据");
    }

    /**
     * 获取预约咨询详细信息
     */
    @PreAuthorize("@ss.hasPermi('zzw:booking:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(zzwBookingInfoService.selectZzwBookingInfoById(id));
    }

    /**
     * 新增预约咨询
     */

    @PostMapping
    public AjaxResult add(@RequestBody ZzwBookingInfo zzwBookingInfo)
    {
        return toAjax(zzwBookingInfoService.insertZzwBookingInfo(zzwBookingInfo));
    }

    /**
     * 修改预约咨询
     */
    @PreAuthorize("@ss.hasPermi('zzw:booking:edit')")
    @Log(title = "预约咨询", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZzwBookingInfo zzwBookingInfo)
    {
        return toAjax(zzwBookingInfoService.updateZzwBookingInfo(zzwBookingInfo));
    }

    /**
     * 删除预约咨询
     */
    @PreAuthorize("@ss.hasPermi('zzw:booking:remove')")
    @Log(title = "预约咨询", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(zzwBookingInfoService.deleteZzwBookingInfoByIds(ids));
    }
}


